# Maintainer: Jelle van der Waa <jelle@archlinux.org>
# Contributor: Eli Schwartz <eschwartz93@gmail.com>

_pkgname=unrardll
pkgname=python-unrardll
pkgver=0.1.7
pkgrel=1
pkgdesc="Python wrapper for UnRAR DLL"
arch=('loong64' 'x86_64')
url="https://github.com/kovidgoyal/${_pkgname}"
license=('BSD')
depends=('libunrar' 'python')
makedepends=('python-setuptools')
source=("https://pypi.io/packages/source/${_pkgname:0:1}/${_pkgname}/${_pkgname}-${pkgver}.tar.gz"{,.asc})
sha256sums=('e1067fe27bb4de204ef8f3692f23d93c5d3b4292f78b292c6fc7dc4f75749f76'
            'SKIP')
b2sums=('92f852ed9cbc02d4c48093dbd5a7f64f4bc279a7b3a3018247a832a61c263b3be19ec5ea94ffdc78c85bd2737647cc3eb231ae9d0953da1de5f23002e7e6ffdc'
        'SKIP')
validpgpkeys=('3CE1780F78DD88DF45194FD706BC317B515ACE7C')

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}"

  python setup.py build
}

check() {
  cd "${srcdir}/${_pkgname}-${pkgver}"

  local python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-cpython-${python_version}" python -m unittest test/basic.py
}

package() {
  cd "${srcdir}/${_pkgname}-${pkgver}"

  python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
